package com.cleaningcloud.erp.api.factory;

import com.cleaningcloud.common.core.domain.R;
import com.cleaningcloud.erp.api.RemoteCustomerService;
import com.cleaningcloud.erp.api.domain.ErpCustomer;
import com.cleaningcloud.erp.api.model.LoginCustomer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RemoteCustomerFallbackFactory implements FallbackFactory<RemoteCustomerService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteCustomerFallbackFactory.class);
    @Override
    public RemoteCustomerService create(Throwable throwable) {
        log.error("三才环科商城服务调用失败:{}", throwable.getMessage());

        return new RemoteCustomerService() {

            @Override
            public R<LoginCustomer> getCustomerInfo(String userName,String source) {
                return R.fail("获取用户信息失败:" + throwable.getMessage());
            }

            @Override
            public R<Boolean> registerCustomerInfo(ErpCustomer erpCustomer, String source) {
                return R.fail("注册失败:" + throwable.getMessage());
            }
        };
    }
}
